#include <stdio.h>
#include "ofc/DBZipFile.h"

int main(int argc, char *argv[])
{
#ifdef HAVE_DBZIPFILE
  DBZipFile *file = [DBZipFile new];
  DText     *str;

  char       name[] = "output.bz2";

  if ([file open :name :"w"])          // Open a bzipped text file for writing
  {
    if (![file writeLine :"A line full of text .."])
      printf("\"%s\" could not be written: %d\n", name, [file error]);

    [file close];
    
    printf("\"%s\" succesfull written.\n", name);
  }
  else
    printf("\"%s\" could not be opened: %d\n", name, [file error]);
  
  
  if ([file open :name :"r"])          // Open a bzipped text file for reading
  {
    while (![file isEof])                // Read all lines
    {
      str = [file readLine];

      printf("%s\n", [str cstring]);

      [str free];
    }
    
    [file close];

    printf("\"%s\" succesfull read.\n", name);
  }
  else
    printf("\"%s\" could not be opened: %d\n", name, [file error]);

  [file free];
#else
  printf("DBZipFile is not present in the library.\n");
#endif
  return 0;
}

